-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
General tweaks & actual code generation for int f() { return 5; }
#7
Conversation
Makes debugging errors easier
This is the same as test_RETURN but with constant 5678 instead of 10
…anging test from stalling the rest
Directives were also moved to FunctionDefinition as there was a bit too much code in main()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yet another great set of changes! The repo is getting more and more professional, especially for a coursework 😄 I especially like providing the two ways of going about the grammar (simplified vs full) as it should give the students an interesting design choice.
I have a few suggestions, which can be summarised as (please make sure I marked all the relevant code snippets):
- using snake_case for variable names to easily distinguish them from functions and classes also somewhat adhere to Google's style guide
- keeping the implementations of
emitRISC
(and the newly introducedprint
for that matter) in separate.cpp
files as that's a general good practice and it would be consistent with otheremitRISC
implementations (which will especially make a lot of sense in cases where the implementation will require dozens of code lines) - making all
emitRISC
andprint
functions consistentlyconst override
for reminding students about inheritance and having a compiler do a sanity check as well. - using initializer list when applicable
I also wanted to discuss some things:
- Do you think we should keep a reminder in every
emitRISC
andprint
function we provide that it's a simple dummy version and they should change it? Or just mention that in the specs (which I think we already do) and keep the code a bit cleaner? - I'm not sure I see the point of replacing specific
jump_statement
(.hpp
/.cpp
) withstatements
(.hpp
/.cpp
) that I assume would include definitions and implementations of all kinds of statements. To me it seems more error-prone and less consistent with how other.cpp
/.hpp
relate to ast nodes. - Given the new simplified grammar, I'd say we actually go a step further and delete some of the "chains" of rules that introduce nothing (...
shift_expression
->additive_expression
->multiplicative_expression
->cast_expression
... etc.) in order to make the grammer even less daunting while giving the students complete freedom in how they go about implementing features should they choose the simple grammar as the starting point. In a way that would further cater students who don't want to fully understand the official grammar and just want to make small steps towards the featutes that seem feasible at the time to them.
Btw, would you mind removing "[WIP]" from somewhere in the changelog, as I forgot and wanted to avoid creating a new pull request just for that? And also, another pull request from a student happened in parallel to yours and there seems to be overlap - would you mind committing theirs idea (quite small) here, so that we could avoid a merge conflict? |
958d3f3
to
fe35d61
Compare
Thanks for the review :) Top four suggestions have been implemented and the Stderr WarningsI've omitted the Long grammar chainAs for the long chain in the grammar, I had a think about this and thought it was probably better to keep. I say this for two reasons:
I did move it to the bottom of the grammar file though so it's seen last when going through the grammar. Jump statement fileI've renamed from |
What does this PR do?
int f() { return 5; }
(@Fiwo735 would you be able to update your image to add INT_CONSTANT to the bottom of it :))int f() { return 5678; }
, since we previously had three of these with just different constant numbers,main()
, such that it is much clearer what's going onlcov
to the Dockerfile, such that Quentin's coverage code will now work inside the container environmenttest.sh
early ifmake
failstest.sh
to be much more human readableprint
method toNode
to allow for the parsed AST to be visualised.gitignore
to ignore coverage and dependency filesint f() { return 5; }
. Note that the full grammar file is retained and docs have been added around how it can be used (using the full grammar does massively increase test time).NodeList
helper class and demonstrates its use for places in the grammar where a list of nodes are requiredCOVERAGE=1 ./test.sh
to allow for args to the script to be used for other purposes in the future (such as paths of specific tests to run)Comments on ASAN
Since ASAN (AddressSanitizer) is turned on, segfaults can easily be diagnosed by reading the log output from stderr (saved into the bin/output directory when you run
./test.sh
). This gives a nice stack trace with the problematic line number.Students will only see this if they navigate to the log file for the test (e.g. the first file in the console output below). In other words, they won't likely see it until they start hunting around the log files when they're having problems getting a test to pass.
To prevent ASAN from changing the compiler exit code, I've set
ASAN_OPTIONS=exitcode=0
to allow the tests intest.sh
to still be attempted even if these logs are produced.